package com.doublefish.doublefishrobot.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.doublefish.doublefishrobot.R;

/**
 * 作者:dugaofeng on 2024/10/21 08:49
 */
public class LoadingDialog extends Dialog {

    private ProgressBar progressBar;
    private TextView msgTxt;

    private Context mContext;
    private String msg;

    public LoadingDialog(Context context) {
        super(context,  R.style.dialog);

        this.mContext = context;
    }

    public LoadingDialog setMsg(String msg) {
        this.msg = msg;
        if (this.msgTxt != null) {
            this.msgTxt.setText(msg);
        }
        return this;
    }



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loading);
        setCanceledOnTouchOutside(false);
        initView();
    }

    private void initView() {
        progressBar = (ProgressBar) findViewById(R.id.progress);
        msgTxt = (TextView) findViewById(R.id.tv_msg);

        msgTxt.setText(msg);

    }

}
